// featurePackage/pages/myMoney/myMoney.js
import {
  myBalanceDetail,
  myBalanceList
} from "../../../service/jb_scoreAndMoney_service"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    balanceDetail: {
      nowMoney: 0,
      orderStatusSum: 0,
      recharge: 0,
    },
    page: 1,
    listType: '',//余额记录，来源和提现的
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },



  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.queryMyBalanceDetail();
  },
  queryMyBalanceDetail() {
    wx.showLoading();
    myBalanceDetail().then(res => {
      wx.hideLoading();
      if (res.code == 200) {
        this.setData({
          balanceDetail: res.data
        })
      }
    }).catch(err => {
      wx.hideLoading();
      wx.showToast({
        title: err || '加载失败',
        icon: "none"
      })
      console.error("JJLog:myBalanceDetail", err);
    })
  },

  queryMyBalanceList(loadType) {
    if (loadType) {
      wx.showLoading();
    }
    myBalanceList(this.data.page, this.data.listType).then(res => {
      wx.hideLoading();
      if (res.code == 200) {
        // this.setData({
        //   balanceDetail: res.data
        // })
      }
    }).catch(err => {
      wx.hideLoading();
      wx.showToast({
        title: err || '加载失败',
        icon: "none"
      })
      console.error("JJLog:myBalanceList", err);
    })
  },








  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})